package org.testfire.translator.watij.assertions;

import org.testfire.model.assertions.AssertEquals;
import org.testfire.model.TestsetType;
import org.testfire.translator.TestFireTranslator;
import org.testfire.translator.TranslatorFactory;

/**
 * Created by IntelliJ IDEA.
 * User: granum
 * Date: Sep 2, 2007
 * Time: 5:49:04 PM
 *
 */
public class AssertEqualsTranslator<T> implements TestFireTranslator<AssertEquals>
{

    public Object translate( TestsetType testset, AssertEquals type )
    {
        StringBuilder buf = new StringBuilder();
        String exp = String.valueOf( type.getExpected() );
        exp = type.isOfStringType() ? '"' + exp + '"' : exp;
        String act = TranslatorFactory.translate(testset,  type.getFinder() ).toString();
        //act = type.isOfStringType() ? '"' + act + '"' : act;
        buf.append( String.format( "assertEquals( \"%1$s\", %2$s, %3$s )", type.getMessage(), exp, act ) );
        return buf.toString();
    }
}